package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /**
     * 动态查询
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> queryByUserId(ShoppingCart shoppingCart);

    /**
     * 修改数量
     * @param shoppingCart1
     */
    @Update("update shopping_cart set number = #{number} where user_id = #{userId}")
    void addend(ShoppingCart shoppingCart1);

    /**
     * 添加购物车
     * @param shoppingCart
     */
    @Insert("insert into shopping_cart values(null, #{name}, #{image}, #{userId}, #{dishId}," +
            "#{setmealId}, #{dishFlavor}, #{number}, #{amount}, #{createTime})")
    void add(ShoppingCart shoppingCart);

    /**
     * 查看购物车
     */
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> queryByUserIdList(Long userId);

    /**
     * 清空购物车
     * @param userId
     */
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteAll(Long userId);


    /**
     * 删除购物车中一个商品
     * @param shoppingCart1
     */
    void deleteById(ShoppingCart shoppingCart1);

    /**
     *
     * @param shoppingCart1
     */
    void updateNumber(ShoppingCart shoppingCart1);
}
